import {Pipe, PipeTransform} from '@angular/core';

@Pipe({
  name: 'sys-dict'
})
export class SystemDictPipe implements PipeTransform {

  constructor() {
  }

  transform(value: any, type: any): any {
    const array = JSON.parse(sessionStorage.getItem('type'));
    if (array) {
      let data;
      for (const arr of array) {
        if (arr.value === value) {
          data = arr.desc;
        }
      }
      if (data === undefined) {
        return value;
      } else {
        return data;
      }
    } else {
      return value;
    }
  }
}
